<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>XenC: include/ppl.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">XenC
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">Open-source tool for data selection in NLP</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">ppl.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="ppl_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment">/*  This file is part of the cross-entropy tool for data selection (XenC)</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> *  aimed at speech recognition and statistical machine translation.</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment"> *  Copyright 2013-2016, Anthony Rousseau, LIUM, University of Le Mans, France</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> *  Development of the XenC tool has been partially funded by the</span></div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> *  European Commission under the MateCat project.</span></div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> *  The XenC tool is free software; you can redistribute it and/or modify it</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment"> *  under the terms of the GNU Lesser General Public License version 3 as</span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment"> *  published by the Free Software Foundation</span></div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment"> *  This library is distributed in the hope that it will be useful, but WITHOUT</span></div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment"> *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or</span></div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="comment"> *  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License</span></div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="comment"> *  for more details.</span></div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="comment"> *  You should have received a copy of the GNU Lesser General Public License</span></div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="comment"> *  along with this library; if not, write to the Free Software Foundation,</span></div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="comment"> *  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span></div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="comment"> */</span></div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="preprocessor">#ifndef PPL_H_</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#define PPL_H_</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">#include &lt;math.h&gt;</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="preprocessor">#include &quot;utils/threadpool.hpp&quot;</span></div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="corpus_8h.html">corpus.h</a>&quot;</span></div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="phrasetable_8h.html">phrasetable.h</a>&quot;</span></div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_xen_l_mken_8h.html">XenLMken.h</a>&quot;</span></div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="preprocessor">#ifndef M_LN10</span></div><div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="ppl_8h.html#a0a53871497a155afe91424c28a8ec3c4">   42</a></span>&#160;<span class="preprocessor">#define M_LN10  2.30258509299404568402</span></div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<span class="keyword">using namespace </span><a class="code" href="namespaceboost_1_1threadpool.html">boost::threadpool</a>;</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;<span class="keywordtype">void</span> <a class="code" href="ppl_8h.html#a0c876aa154ae0422fad090aad9f79b7f">taskCalcPPL</a>(<span class="keywordtype">int</span> numLine, std::string line, boost::shared_ptr&lt;std::vector&lt;double&gt; &gt; ptrPPL, boost::shared_ptr&lt;XenLMken&gt; ptrLM);</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;</div><div class="line"><a name="l00065"></a><span class="lineno"><a class="line" href="class_p_p_l.html">   65</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_p_p_l.html">PPL</a> {</div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;    <a class="code" href="class_p_p_l.html">PPL</a>();</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    </div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    <span class="keywordtype">void</span> initialize(boost::shared_ptr&lt;Corpus&gt; ptrCorp, boost::shared_ptr&lt;XenLMken&gt; ptrLM);</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    </div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    <span class="keywordtype">void</span> initialize(boost::shared_ptr&lt;PhraseTable&gt; ptrPT, boost::shared_ptr&lt;XenLMken&gt; ptrLM, <span class="keywordtype">bool</span> source);</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    </div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    ~<a class="code" href="class_p_p_l.html">PPL</a>();</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;    </div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getSize() <span class="keyword">const</span>;</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;    </div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;    <span class="keywordtype">double</span> getPPL(<span class="keywordtype">int</span> n);</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;    </div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    <span class="keywordtype">double</span> getXE(<span class="keywordtype">int</span> n);</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    </div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    <span class="keywordtype">double</span> getCorpPPL();</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;    </div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;    <span class="keywordtype">void</span> calcPPLCorpus();</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;    </div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    <span class="keywordtype">void</span> calcPPLPhraseTable();</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;    boost::shared_ptr&lt;XenLMken&gt; ptrLM;                  </div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;    boost::shared_ptr&lt;Corpus&gt; ptrCorp;                  </div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    boost::shared_ptr&lt;PhraseTable&gt; ptrPT;               </div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;    <span class="keywordtype">bool</span> source;                                        </div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;    boost::shared_ptr&lt;std::vector&lt;double&gt; &gt; ptrPPL;     </div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;</div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">double</span> crossEntropy(<span class="keywordtype">double</span> ppl);</div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;};</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;<span class="preprocessor">#endif</span></div><div class="ttc" id="_xen_l_mken_8h_html"><div class="ttname"><a href="_xen_l_mken_8h.html">XenLMken.h</a></div><div class="ttdoc">Class handling KenLM estimation, loading, querying... </div></div>
<div class="ttc" id="phrasetable_8h_html"><div class="ttname"><a href="phrasetable_8h.html">phrasetable.h</a></div><div class="ttdoc">Class handling phrase-table related functionalities. </div></div>
<div class="ttc" id="namespaceboost_1_1threadpool_html"><div class="ttname"><a href="namespaceboost_1_1threadpool.html">threadpool</a></div><div class="ttdoc">Forward declaration. </div></div>
<div class="ttc" id="class_p_p_l_html"><div class="ttname"><a href="class_p_p_l.html">PPL</a></div><div class="ttdoc">Perplexity/Cross-entropy computations. </div><div class="ttdef"><b>Definition:</b> ppl.h:65</div></div>
<div class="ttc" id="corpus_8h_html"><div class="ttname"><a href="corpus_8h.html">corpus.h</a></div><div class="ttdoc">Class handling corpus-related functionalities. </div></div>
<div class="ttc" id="ppl_8h_html_a0c876aa154ae0422fad090aad9f79b7f"><div class="ttname"><a href="ppl_8h.html#a0c876aa154ae0422fad090aad9f79b7f">taskCalcPPL</a></div><div class="ttdeci">void taskCalcPPL(int numLine, std::string line, boost::shared_ptr&lt; std::vector&lt; double &gt; &gt; ptrPPL, boost::shared_ptr&lt; XenLMken &gt; ptrLM)</div><div class="ttdoc">Thread-safe perplexity computation function. </div><div class="ttdef"><b>Definition:</b> ppl.cpp:35</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Mar 18 2016 17:22:37 for XenC by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
